package com.wuzf.service.impl;

import java.util.Set;

import com.wuzf.dao.UserDao;
import com.wuzf.dao.impl.UserDaoImpl;
import com.wuzf.entity.User;
import com.wuzf.service.UserService;
import com.wuzf.utils.PasswordHelper;


public class UserServiceImpl implements UserService{
	
	private PasswordHelper passwordHelper = new PasswordHelper();
	
	private UserDao dao = new UserDaoImpl();
	
	public User createUser(User user) {
		passwordHelper.encryptPassword(user);
		User u = dao.createUser(user);
		if (u != null) {
			return u;
		}
		return null;
	}

	public void changePassword(Long userId, String newPassword) {
		// TODO Auto-generated method stub
		
	}

	public void correlationRoles(Long userId, Long... roleIds) {
		// TODO Auto-generated method stub
		dao.correlationRoles(userId, roleIds);
	}

	public void uncorrelationRoles(Long userId, Long... roleIds) {
		// TODO Auto-generated method stub
		
	}

	public User findByUsername(String username) {
		return dao.findByUsername(username);
	}

	public Set<String> findRoles(String username) {
		return dao.findRoles(username);
	}

	public Set<String> findPermissions(String username) {
		return dao.findPermissions(username);
	}
	
}
